package com.lqq.school.controller;


import com.lqq.school.domain.TempRecord;
import com.lqq.school.mapper.TempRecordMapper;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lqq
 * @since 2021-06-12
 */
@Controller
public class TempRecordController {
    @Resource
    private TempRecordMapper tempRecordMapper;
    @GetMapping("/toTemp")
    public String toTemp() {
        return "/stu/temp";
    }

    @GetMapping("/tempList")
    public String tempList(Model model) {
        List<TempRecord> tempRecords = tempRecordMapper.selectList(null);

        model.addAttribute("list", tempRecords);
        return "/admin/templist";
    }
    @PostMapping("/temp")
    public String temp(TempRecord tempRecord) {
        int cow = tempRecordMapper.insert(tempRecord);
        if (cow > 0) {
            System.out.println("打卡体温成功！");
        }
        return "redirect:/stu/main";
    }
}

